#ifndef MODEL_H
#define MODEL_H

#include <string>
#include <vector>
#include <map>
#include <ctime>

namespace nanok {

struct ObjectMeta {
    std::string name;
    std::string namespace_;
    int64_t resourceVersion;
    
    ObjectMeta() : resourceVersion(1) {}
};

struct Container {
    std::string name;
    std::string image;
    int port;
    
    Container() : port(0) {}
};

struct PodSpec {
    std::vector<Container> containers;
};

struct PodStatus {
    std::string phase;
    std::string hostIP;
    std::string podIP;
    std::string startTime;
    
    PodStatus() : phase("Pending") {}
};

struct Pod {
    ObjectMeta metadata;
    PodSpec spec;
    PodStatus status;
};

struct NodeSpec {
    std::string podCIDR;
};

struct NodeStatus {
    std::map<std::string, std::string> capacity;
    std::map<std::string, std::string> allocatable;
    
    NodeStatus() {
        capacity["cpu"] = std::string("4");
        capacity["memory"] = "16Gi";
        allocatable["cpu"] = std::string("4");
        allocatable["memory"] = "16Gi";
    }
};

struct Node {
    ObjectMeta metadata;
    NodeSpec spec;
    NodeStatus status;
};

struct TaskSpec {
    std::string podName;
    std::string assignedNode;
    
    TaskSpec() : assignedNode("") {}
};

struct Task {
    ObjectMeta metadata;
    TaskSpec spec;
};

// JSON 序列化/反序列化函数
std::string to_json(const Pod& pod);
std::string to_json(const Node& node);
std::string to_json(const Task& task);

bool from_json(const std::string& json, Pod& pod);
bool from_json(const std::string& json, Node& node);
bool from_json(const std::string& json, Task& task);

} // namespace nanok

#endif // MODEL_H